<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>计算天数</title>
	</head>
	<body>
		// 练习1
					// 1. 编写一个函数,传入年月日,计算并返回这天是这一年的第几天。
					// 用以下代码测试:
		<script type="text/javascript">
			     			function day(n,y,r)
						{
							var days=0;
							switch(y)
							{
								case 1:
									days=r; break;
								case 2:
									days=31+r; break;
								case 3:
									days=31+28+r; break;
								case 4:
									days=31+28+31+r; break;
								case 5:
									days=31+28+31+30+r; break;
								case 6:
									days=31+28+31+30+31+r; break;
								case 7:
									days=31+28+31+30+31+30+r; break;
								case 8:
									days=31+28+31+30+31+30+31+r; break;
								case 9:
									days=31+28+31+30+31+30+31+31+r; break;
								case 10:
									days=31+28+31+30+31+30+31+31+30+r; break;
								case 11:
									days=31+28+31+30+31+30+31+31+30+31+r; break;
								case 12:
									days=31+28+31+30+31+30+31+31+30+31+30+r; break;	
							}
							if(n%4==0){days=days+1;}
							return days;
						}
						num3=day(2024,5,20);
						document.write(num3)
		</script>
	</body>
</html>
